import QtQuick
import QtQuick.Controls

Rectangle {
    id: root
    width: 400
    height: 400

    AnimatedImage {
        id: img
        source: "qrc:/images/huaji.gif"
        x: 0
        y: 150
        width: 100
        height: 100

        // 属性动画
        PropertyAnimation on x {
            id: propAnim
            to: 300
            duration: 500
            running: false

            onStopped: {
                to = to===300 ? 0 : 300
            }
        }
    }

    Button {
        text: "启动属性动画"
        anchors.bottom: parent.bottom
        onClicked: {
            if (propAnim.running) return;
            propAnim.start();
        }
    }
}
